package com.eastcom.providor.service.extview;

import java.util.ArrayList;
import java.util.List;

import com.eastcom.bm.atom.Atom_KpiDefine;
import com.eastcom.bm.atom.Atom_NeSpecialThreadhold;
import com.eastcom.client.DatasetBean;
import com.eastcom.client.KpiAndThBean;

public class KpiAndThreadholdUtil {

	public static List<Atom_KpiDefine> createKpiDefines(List<Atom_KpiDefine> kpiDefines){
		if(kpiDefines==null||kpiDefines.isEmpty())
			return null;
		
		List<Atom_KpiDefine> results=new ArrayList<Atom_KpiDefine>();
		for(Atom_KpiDefine kpiDefine:kpiDefines){
			Atom_KpiDefine result=new Atom_KpiDefine();
			result.setId(kpiDefine.getId());
			result.setCn_name(kpiDefine.getCn_name());
			result.setBaselineValue(kpiDefine.getBaselineValue());
			result.setDeviationDown(kpiDefine.getDeviationDown());
			result.setDeviationUp(kpiDefine.getDeviationUp());
			result.setThreadHoldDown(kpiDefine.getThreadHoldDown());
			result.setThreadHoldUp(kpiDefine.getThreadHoldUp());
			result.setKpiId(kpiDefine.getKpiId());
			result.setValidationType(kpiDefine.getValidationType());
			result.setColumnName(kpiDefine.getColumnName());
			result.setCalendarPolicyUUID(kpiDefine.getCalendarPolicyUUID());
			results.add(result);
		}
		
		return results;
	}
	
	public static List<Atom_KpiDefine> createKpiDefines(DatasetBean bean){
		List<Atom_KpiDefine> kpis=new ArrayList<Atom_KpiDefine>();
		if(bean.getDataset_id()==null||bean.getKpiAndThs()==null)
			return kpis;
		for(KpiAndThBean b:bean.getKpiAndThs()){
			Atom_KpiDefine at=new Atom_KpiDefine();
			at.setId(b.getKpi_id());
			at.setBaselineValue(b.getKpi_baselineValue());
			at.setCn_name(b.getKpi_cn_name());
			//at.setDatasetId(b.getKpi_datasetId());
			at.setDeviationDown(b.getKpi_deviationDown());
			at.setDeviationUp(b.getKpi_deviationUp());
			at.setThreadHoldDown(b.getKpi_threadHoldDown());
			at.setThreadHoldUp(b.getKpi_threadHoldUp());
			at.setValidationType(b.getKpi_validationType());
			kpis.add(at);
		}
		return kpis;
	}
	
	public static List<Atom_NeSpecialThreadhold> createNeSpecialThreadhold(DatasetBean bean){
		List<Atom_NeSpecialThreadhold> neTHs=new ArrayList<Atom_NeSpecialThreadhold>();
		if(bean.getDataset_id()==null||bean.getKpiAndThs()==null)
			return neTHs;
		
		/*
		for(KpiAndThBean b:bean.getKpiAndThs()){
			if(b.getTh_neId()!=null&&!b.getTh_neId().trim().equals("")){
				Atom_NeSpecialThreadhold at=new Atom_NeSpecialThreadhold();
				at.setNeId(b.getTh_neId());
				//at.setId(id)
				at.setKpiId(b.getKpi_id());
				at.setBaselineValue(b.getTh_baselineValue());
				at.setCalendarPolicyUUID(b.getTh_calendarPolicyUUID());
				at.setDeviationDown(b.getTh_deviationDown());
				at.setDeviationUp(b.getTh_deviationUp());
				
				at.setThreadHoldDown(b.getTh_threadHoldDown());
				at.setThreadHoldUp(b.getTh_threadHoldUp());
				at.setValidationType(b.getTh_validationType());
				neTHs.add(at);
			}
		}
		*/
		return neTHs;
		
	}
}
